﻿Imports System.Data.OleDb
Public Class TimKiemDAO
    Public Function TimKiemNV(TenBang As String, NoiDung As String) As DataTable
        ' Dim sql As String = "select * from " + TenBang + " where MaNV like + '%" & NoiDung + "%' or TenNV like '%" & NoiDung & "%' "
        Dim sql As String = "select * from NhanVien where MaNV like + '%" & NoiDung + "%' or TenNV like '%" & NoiDung & "%'"
        Dim dt As New DataTable
        Dim cn As OleDbConnection = DataProvider.OpenConnect
        Dim da As New OleDbDataAdapter(sql, cn)
        Try
            da.Fill(dt)
        Catch
            MessageBox.Show("Khong tim thay du lieu")
        End Try
        cn.Close()
        Return dt
    End Function
    Public Function TimKiemKH(TenBang As String, NoiDung As String) As DataTable
        Dim sql As String = "select * from KhachHang where MaKH like + '%" & NoiDung + "%' or TenKH like '%" & NoiDung & "%'"
        Dim dt As New DataTable
        Dim cn As OleDbConnection = DataProvider.OpenConnect
        Dim da As New OleDbDataAdapter(sql, cn)
        Try
            da.Fill(dt)
        Catch
            MessageBox.Show("Khong tim thay du lieu")
        End Try
        cn.Close()
        Return dt
    End Function
    Public Function TimKiemTD(TenBang As String, NoiDung As String) As DataTable
        Dim sql As String = "select * from ThucDon where MaMonAn like + '%" & NoiDung + "%' or TenMonAn like '%" & NoiDung & "%'"
        Dim dt As New DataTable
        Dim cn As OleDbConnection = DataProvider.OpenConnect
        Dim da As New OleDbDataAdapter(sql, cn)
        Try
            da.Fill(dt)
        Catch
            MessageBox.Show("Khong tim thay du lieu")
        End Try
        cn.Close()
        Return dt
    End Function
    Public Function TimKiemNL(TenBang As String, NoiDung As String) As DataTable
        Dim sql As String = "select * from NguyenLieu where MaNL like + '%" & NoiDung + "%' or TenNL like '%" & NoiDung & "%'"
        Dim dt As New DataTable
        Dim cn As OleDbConnection = DataProvider.OpenConnect
        Dim da As New OleDbDataAdapter(sql, cn)
        Try
            da.Fill(dt)
        Catch
            MessageBox.Show("Khong tim thay du lieu")
        End Try
        cn.Close()
        Return dt
    End Function
    Public Function TimKiemNhaCungCap(TenBang As String, NoiDung As String) As DataTable
        Dim sql As String = "select * from NhaCungCap where MaNhaCungCap like + '%" & NoiDung + "%' or TenNhaCungCap like '%" & NoiDung & "%'"
        Dim dt As New DataTable
        Dim cn As OleDbConnection = DataProvider.OpenConnect
        Dim da As New OleDbDataAdapter(sql, cn)
        Try
            da.Fill(dt)
        Catch
            MessageBox.Show("Khong tim thay du lieu")
        End Try
        cn.Close()
        Return dt
    End Function
End Class
